home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 May: Tool Chest / Dev.CD May 97 TC.toast / Sample Code / Snippets / Development Tools & Languages / Low Level Debugger macros / Definitions.h
Encoding:
Text File  |  1992-07-15  |  3.0 KB  |  110 lines  |  [TEXT/MPS ]

  1. //     Definitions.h
  2. //     Copyright ©1992 Apple Computer, Inc.
  3. //    Kent Sandvik DTS
  4. //    This file contains debugger macros
  5.  
  6. #ifndef __DEFINITIONS__
  7. #define __DEFINITIONS__
  8.  
  9.  
  10. /*     DEBUGGER FLAGS
  11.     MacApp 3.0 has many special flags which could be turned on/off from the
  12.     debug menu entry. We are mostly interested in signalling something from
  13.     the application to the source code, so we are interested to use:
  14.     
  15.     gIntenseDebugging - turn on intense debugging, it will also signal to the
  16.     framework to start tracing many other things, so it's very costly.
  17.     
  18.     gUserFlag1, gUserFlag2, gUserFlag3 - these are better suited for special control
  19.     that we know about. In this case we are using gUserFlag1.
  20.     
  21.     WHY DON'T YOU USE MACROS, INSTEAD OF INLINE FUNCTIONS?
  22.     Because I'm sick-n-tired of tracing macro based problems. It should not matter,
  23.     we are still inlining code directly instead of calling functions. Also, then
  24.     I'm able to use static variables for certain 'macros' which should only do something
  25.     based on earlier state.
  26.     
  27.     TMON USE
  28.     These macros are defined for MacsBug, i.e. they start with a ';' in the beginning
  29.     of the string. If you want to use TMON, change the ';' to a '™' and also change the debugger
  30.     statement to something suitable in the TMON world. BTW, these macros are based on
  31.     MacsBug 6.2.2.
  32.     
  33. */
  34.  
  35. //    Globals
  36.     Boolean gHeapScramble     = FALSE;        // heap scrambling
  37.     Boolean gLeaks             = FALSE;        // if Leaks DCMD is installed, test for memory leaks
  38.     
  39.     
  40. inline void DBOUTPUT(CStr255 a) //    Call debugger with a string - used for other macros.
  41.     if(gUserFlag1) DebugStr(a);
  42. }
  43.  
  44.  
  45. inline void DBHEAPCHECK()         //    Heap Check - check for heap status, it stops if something is wrong
  46.     DBOUTPUT(";HC; G");
  47. }
  48.  
  49. inline void DBHEAPCHECKLOG()     //    Heap Check variation - log information inside a log file
  50. {
  51.     DBOUTPUT("Extended Heap Check:; LOG HeapTest; WH; HC; HZ; LOG; G"); 
  52. }
  53.  
  54.  
  55. inline void DBHEAPSCRAMBLEON()     //    Turn on Heap Scramble
  56.     if (!gHeapScramble){
  57.         DBOUTPUT("Heap Scramble ON; HS; G");
  58.         gHeapScramble = TRUE;
  59.     }
  60. }
  61.  
  62.  
  63. inline void DBHEAPSCRAMBLEOFF() //    Turn off Heap Scramble
  64.     if(gHeapScramble){
  65.         DBOUTPUT("Heap Scramble OFF; HS; G");
  66.         gHeapScramble = FALSE;
  67.     }
  68. }
  69.  
  70.  
  71. inline void DBHEAPINFOLOG()        //    Log Heap information into log
  72. {
  73.     DBOUTPUT("Heap Info:; LOG HeapInfo; WH; HT; HD RS; LOG; G"); 
  74. }
  75.  
  76.  
  77. inline void DBEVENTRECORDLOG()     // Log Event Records at particular instanced
  78. {
  79.     DBOUTPUT("Event Record:; LOG EventRecordLog; WH; DM 000234C4 EventRecord; LOG; G");
  80. }
  81.  
  82.  
  83. inline void DBLEAKSON()     //    Turn on Leaks dcmd (assume we have it installed, if not it's on Developer CD)
  84.     if (!gLeaks){
  85.         DBOUTPUT("Leaks ON; Leaks On; G");
  86.         gLeaks = TRUE;
  87.     }
  88. }
  89.  
  90.  
  91. inline void DBLEAKSOFF()     //    Turn off Leaks dcmd
  92.     if(gLeaks){
  93.         DBOUTPUT("Leaks OFF; Leaks Off; G");
  94.         gLeaks = FALSE;
  95.     }
  96. }
  97.  
  98.  
  99. //… I think you got the idea now, feel free to create any other MacsBug/low level debugger
  100. //    commands which could be used from debug mode (or actually any other Macintosh source code
  101.     which could set a flag dynamically from a menu entry).
  102.  
  103.  
  104. #endif  __DEFINITIONS__